/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/*
 * JFrameMain.java
 *
 * Created on 31/10/2011, 15:50:22
 */
package br.com.seguradora.view;

import br.com.seguradora.view.dialog.AssociadoDialog;
import br.com.seguradora.view.dialog.ConsultaAssociadoDialog;
import br.com.seguradora.view.dialog.ConsultaEnderecoDialog;
import br.com.seguradora.view.dialog.ConsultaGrupoDialog;
import br.com.seguradora.view.dialog.ConsultaMarcaDialog;
import br.com.seguradora.view.dialog.ConsultaModeloDialog;
import br.com.seguradora.view.dialog.ConsultaOficinaDialog;
import br.com.seguradora.view.dialog.ConsultaPlanoDialog;
import br.com.seguradora.view.dialog.ConsultaRateioDialog;
import br.com.seguradora.view.dialog.ConsultaSinistroDialog;
import br.com.seguradora.view.dialog.ConsultaUsuarioDialog;
import br.com.seguradora.view.dialog.ConsultaVeiculoDialog;
import br.com.seguradora.view.dialog.ConsultaVistoriaDialog;
import br.com.seguradora.view.dialog.CreateSinistroDialog;
import br.com.seguradora.view.dialog.CreateVistoriaDialog;
import br.com.seguradora.view.dialog.EnderecoDialog;
import br.com.seguradora.view.dialog.GrupoDialog;
import br.com.seguradora.view.dialog.MarcaDialog;
import br.com.seguradora.view.dialog.ModeloDialog;
import br.com.seguradora.view.dialog.OficinaDialog;
import br.com.seguradora.view.dialog.PlanoDialog;
import br.com.seguradora.view.dialog.VeiculoDialog;
import java.awt.event.ActionEvent;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.JFrame;

/**
 *
 * @author Diego
 */
public class MenuPrincipal extends javax.swing.JFrame {

    public MenuPrincipal() {
        createActions();
        initComponents();
        setExtendedState(JFrame.MAXIMIZED_BOTH);
        setLocationRelativeTo(null);
    }

    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jToolBar1 = new javax.swing.JToolBar();
        associadoButton = new javax.swing.JButton(associadoConsultaAction);
        jSeparator9 = new javax.swing.JToolBar.Separator();
        veiculosButton = new javax.swing.JButton(veiculoConsultaAction);
        veiculosButton1 = new javax.swing.JButton(vistoriaConsultaAction);
        jSeparator10 = new javax.swing.JToolBar.Separator();
        planoButton = new javax.swing.JButton(planoConsultaAction);
        jSeparator12 = new javax.swing.JToolBar.Separator();
        sinistroButton = new javax.swing.JButton(sinistroConsultaAction);
        jSeparator13 = new javax.swing.JToolBar.Separator();
        grupoButton = new javax.swing.JButton(grupoConsultaAction);
        rateioButton = new javax.swing.JButton(rateioConsultaAction);
        jPanel1 = new javax.swing.JPanel();
        contaUsuarioButton = new javax.swing.JButton();
        ajudaButton = new javax.swing.JButton();
        jMenuBar1 = new javax.swing.JMenuBar();
        arquivoMainMenu = new javax.swing.JMenu();
        logoutMenuItem = new javax.swing.JMenuItem();
        jSeparator1 = new javax.swing.JPopupMenu.Separator();
        sairMenuItem = new javax.swing.JMenuItem(finallyApplicationAction);
        controleMainMenu = new javax.swing.JMenu();
        associadoMenuItem = new javax.swing.JMenuItem(associadoConsultaAction);
        planoMenuItem = new javax.swing.JMenuItem(planoConsultaAction);
        jSeparator2 = new javax.swing.JPopupMenu.Separator();
        veiculoMenuItem = new javax.swing.JMenuItem(veiculoConsultaAction);
        veiculoMenuItem1 = new javax.swing.JMenuItem(vistoriaConsultaAction);
        jSeparator8 = new javax.swing.JPopupMenu.Separator();
        modeloMenuItem = new javax.swing.JMenuItem(modeloConsultaAction);
        marcaMenuItem = new javax.swing.JMenuItem(marcaConsultaAction);
        jSeparator5 = new javax.swing.JPopupMenu.Separator();
        sinistroMenuItem = new javax.swing.JMenuItem(sinistroConsultaAction);
        jSeparator11 = new javax.swing.JPopupMenu.Separator();
        grupoMenuItem = new javax.swing.JMenuItem(grupoConsultaAction);
        rateioMenuItem = new javax.swing.JMenuItem(rateioConsultaAction);
        jSeparator3 = new javax.swing.JPopupMenu.Separator();
        oficinaMenuItem = new javax.swing.JMenuItem(oficinaConsultaAction);
        jSeparator4 = new javax.swing.JPopupMenu.Separator();
        enderecoMenuItem = new javax.swing.JMenuItem(enderecoConsultaAction);
        configuracoesMainMenu = new javax.swing.JMenu();
        contaUsuarioMenuItem = new javax.swing.JMenuItem();
        jSeparator7 = new javax.swing.JPopupMenu.Separator();
        usuariosMenuItem = new javax.swing.JMenuItem(usuarioConsultaAction);
        ajudaMainMenu = new javax.swing.JMenu();
        sobreMenuItem = new javax.swing.JMenuItem();

        setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
        setTitle("KM Seguradora 0.0.1 - Menu Principal");

        jToolBar1.setBorder(javax.swing.BorderFactory.createEtchedBorder());
        jToolBar1.setFloatable(false);
        jToolBar1.setRollover(true);
        jToolBar1.setBorderPainted(false);

        associadoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/clients64x64.png"))); // NOI18N
        associadoButton.setToolTipText("Controle de Associados");
        associadoButton.setFocusable(false);
        associadoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        associadoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(associadoButton);
        jToolBar1.add(jSeparator9);

        veiculosButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/car64x64.png"))); // NOI18N
        veiculosButton.setToolTipText("Controle de Veículos");
        veiculosButton.setFocusable(false);
        veiculosButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        veiculosButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(veiculosButton);

        veiculosButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/vistoria64x64.png"))); // NOI18N
        veiculosButton1.setToolTipText("Controle de Vistorias");
        veiculosButton1.setFocusable(false);
        veiculosButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        veiculosButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(veiculosButton1);
        jToolBar1.add(jSeparator10);

        planoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/contract64x64.png"))); // NOI18N
        planoButton.setToolTipText("Controle de Planos");
        planoButton.setFocusable(false);
        planoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        planoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(planoButton);
        jToolBar1.add(jSeparator12);

        sinistroButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/calculator64x64.png"))); // NOI18N
        sinistroButton.setToolTipText("Controle de Sinistros");
        sinistroButton.setFocusable(false);
        sinistroButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        sinistroButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(sinistroButton);
        jToolBar1.add(jSeparator13);

        grupoButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/group64x64.png"))); // NOI18N
        grupoButton.setToolTipText("Controle de Grupos");
        grupoButton.setFocusable(false);
        grupoButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        grupoButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(grupoButton);

        rateioButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/rateio64x64.png"))); // NOI18N
        rateioButton.setToolTipText("Controle de Rateio");
        rateioButton.setFocusable(false);
        rateioButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        rateioButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(rateioButton);

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 112, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 64, Short.MAX_VALUE)
        );

        jToolBar1.add(jPanel1);

        contaUsuarioButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/useraccount48x48.png"))); // NOI18N
        contaUsuarioButton.setToolTipText("Alterar configuração da conta de usuário");
        contaUsuarioButton.setFocusable(false);
        contaUsuarioButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        contaUsuarioButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(contaUsuarioButton);

        ajudaButton.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/help48x48.png"))); // NOI18N
        ajudaButton.setToolTipText("Ajuda");
        ajudaButton.setFocusable(false);
        ajudaButton.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
        ajudaButton.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
        jToolBar1.add(ajudaButton);

        arquivoMainMenu.setMnemonic('a');
        arquivoMainMenu.setLabel("Arquivo");

        logoutMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F, java.awt.event.InputEvent.CTRL_MASK));
        logoutMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/logout.png"))); // NOI18N
        logoutMenuItem.setText("Fechar sessão");
        arquivoMainMenu.add(logoutMenuItem);
        arquivoMainMenu.add(jSeparator1);

        sairMenuItem.setMnemonic('s');
        sairMenuItem.setText("Sair");
        arquivoMainMenu.add(sairMenuItem);

        jMenuBar1.add(arquivoMainMenu);

        controleMainMenu.setMnemonic('c');
        controleMainMenu.setText("Controle");

        associadoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F2, 0));
        associadoMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/clients32x32.png"))); // NOI18N
        associadoMenuItem.setText("Associado...");
        controleMainMenu.add(associadoMenuItem);

        planoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_P, java.awt.event.InputEvent.CTRL_MASK));
        planoMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/contract32x32.png"))); // NOI18N
        planoMenuItem.setText("Plano...");
        controleMainMenu.add(planoMenuItem);
        controleMainMenu.add(jSeparator2);

        veiculoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F6, 0));
        veiculoMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/car32x32.png"))); // NOI18N
        veiculoMenuItem.setText("Veículo...");
        controleMainMenu.add(veiculoMenuItem);

        veiculoMenuItem1.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F7, 0));
        veiculoMenuItem1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/vistoria32x32.png"))); // NOI18N
        veiculoMenuItem1.setText("Vistoria...");
        controleMainMenu.add(veiculoMenuItem1);
        controleMainMenu.add(jSeparator8);

        modeloMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F3, 0));
        modeloMenuItem.setText("Modelo...");
        controleMainMenu.add(modeloMenuItem);

        marcaMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_F4, 0));
        marcaMenuItem.setText("Marca...");
        controleMainMenu.add(marcaMenuItem);
        controleMainMenu.add(jSeparator5);

        sinistroMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_S, java.awt.event.InputEvent.CTRL_MASK));
        sinistroMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/calculator32x32.png"))); // NOI18N
        sinistroMenuItem.setText("Sinistro...");
        controleMainMenu.add(sinistroMenuItem);
        controleMainMenu.add(jSeparator11);

        grupoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_G, java.awt.event.InputEvent.CTRL_MASK));
        grupoMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/group32x32.png"))); // NOI18N
        grupoMenuItem.setText("Grupo...");
        controleMainMenu.add(grupoMenuItem);

        rateioMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_R, java.awt.event.InputEvent.CTRL_MASK));
        rateioMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/rateio32x32.png"))); // NOI18N
        rateioMenuItem.setText("Rateio...");
        controleMainMenu.add(rateioMenuItem);
        controleMainMenu.add(jSeparator3);

        oficinaMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_O, java.awt.event.InputEvent.CTRL_MASK));
        oficinaMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/oficina32x32.png"))); // NOI18N
        oficinaMenuItem.setText("Oficina...");
        controleMainMenu.add(oficinaMenuItem);
        controleMainMenu.add(jSeparator4);

        enderecoMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_E, java.awt.event.InputEvent.CTRL_MASK));
        enderecoMenuItem.setText("Endereço...");
        controleMainMenu.add(enderecoMenuItem);

        jMenuBar1.add(controleMainMenu);

        configuracoesMainMenu.setMnemonic('o');
        configuracoesMainMenu.setText("Configurações");

        contaUsuarioMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_T, java.awt.event.InputEvent.CTRL_MASK));
        contaUsuarioMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/useraccount32x32.png"))); // NOI18N
        contaUsuarioMenuItem.setText("Conta de usuário...");
        configuracoesMainMenu.add(contaUsuarioMenuItem);
        configuracoesMainMenu.add(jSeparator7);

        usuariosMenuItem.setAccelerator(javax.swing.KeyStroke.getKeyStroke(java.awt.event.KeyEvent.VK_U, java.awt.event.InputEvent.CTRL_MASK));
        usuariosMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/usuarios32x32.png"))); // NOI18N
        usuariosMenuItem.setText("Usuários...");
        configuracoesMainMenu.add(usuariosMenuItem);

        jMenuBar1.add(configuracoesMainMenu);

        ajudaMainMenu.setMnemonic('u');
        ajudaMainMenu.setText("Ajuda");

        sobreMenuItem.setIcon(new javax.swing.ImageIcon(getClass().getResource("/br/com/seguradora/resources/help32x32.png"))); // NOI18N
        sobreMenuItem.setMnemonic('o');
        sobreMenuItem.setText("Sobre o Sistema");
        ajudaMainMenu.add(sobreMenuItem);

        jMenuBar1.add(ajudaMainMenu);

        setJMenuBar(jMenuBar1);
        setExtendedState(JFrame.MAXIMIZED_BOTH);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jToolBar1, javax.swing.GroupLayout.DEFAULT_SIZE, 747, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jToolBar1, javax.swing.GroupLayout.PREFERRED_SIZE, 68, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(349, Short.MAX_VALUE))
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    /**
     * @param args the command line arguments
     */
    public static void main(String args[]) {
        //<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
        /* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
         * For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html 
         */
        try {
            javax.swing.UIManager.setLookAndFeel(javax.swing.UIManager.getSystemLookAndFeelClassName());
        } catch (Exception ex) {
            System.out.println(ex);
        }
        //</editor-fold>
        java.awt.EventQueue.invokeLater(new Runnable() {

            public void run() {
                new MenuPrincipal().setVisible(true);
            }
        });
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton ajudaButton;
    private javax.swing.JMenu ajudaMainMenu;
    private javax.swing.JMenu arquivoMainMenu;
    private javax.swing.JButton associadoButton;
    private javax.swing.JMenuItem associadoMenuItem;
    private javax.swing.JMenu configuracoesMainMenu;
    private javax.swing.JButton contaUsuarioButton;
    private javax.swing.JMenuItem contaUsuarioMenuItem;
    private javax.swing.JMenu controleMainMenu;
    private javax.swing.JMenuItem enderecoMenuItem;
    private javax.swing.JButton grupoButton;
    private javax.swing.JMenuItem grupoMenuItem;
    private javax.swing.JMenuBar jMenuBar1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPopupMenu.Separator jSeparator1;
    private javax.swing.JToolBar.Separator jSeparator10;
    private javax.swing.JPopupMenu.Separator jSeparator11;
    private javax.swing.JToolBar.Separator jSeparator12;
    private javax.swing.JToolBar.Separator jSeparator13;
    private javax.swing.JPopupMenu.Separator jSeparator2;
    private javax.swing.JPopupMenu.Separator jSeparator3;
    private javax.swing.JPopupMenu.Separator jSeparator4;
    private javax.swing.JPopupMenu.Separator jSeparator5;
    private javax.swing.JPopupMenu.Separator jSeparator7;
    private javax.swing.JPopupMenu.Separator jSeparator8;
    private javax.swing.JToolBar.Separator jSeparator9;
    private javax.swing.JToolBar jToolBar1;
    private javax.swing.JMenuItem logoutMenuItem;
    private javax.swing.JMenuItem marcaMenuItem;
    private javax.swing.JMenuItem modeloMenuItem;
    private javax.swing.JMenuItem oficinaMenuItem;
    private javax.swing.JButton planoButton;
    private javax.swing.JMenuItem planoMenuItem;
    private javax.swing.JButton rateioButton;
    private javax.swing.JMenuItem rateioMenuItem;
    private javax.swing.JMenuItem sairMenuItem;
    private javax.swing.JButton sinistroButton;
    private javax.swing.JMenuItem sinistroMenuItem;
    private javax.swing.JMenuItem sobreMenuItem;
    private javax.swing.JMenuItem usuariosMenuItem;
    private javax.swing.JMenuItem veiculoMenuItem;
    private javax.swing.JMenuItem veiculoMenuItem1;
    private javax.swing.JButton veiculosButton;
    private javax.swing.JButton veiculosButton1;
    // End of variables declaration//GEN-END:variables
    private Action finallyApplicationAction;
    private Action associadoConsultaAction;
    private Action modeloConsultaAction;
    private Action marcaConsultaAction;
    private Action grupoConsultaAction;
    private Action enderecoConsultaAction;
    private Action oficinaConsultaAction;
    private Action veiculoConsultaAction;
    private Action vistoriaConsultaAction;
    private Action planoConsultaAction;
    private Action sinistroConsultaAction;
    private Action rateioConsultaAction;
    private Action usuarioConsultaAction;

    private void createActions() {
        finallyApplicationAction = new FinallyApplicationAction();
        associadoConsultaAction = new AssociadoAction(true);
        modeloConsultaAction = new ModeloAction(true);
        marcaConsultaAction = new MarcaAction(true);
        grupoConsultaAction = new GrupoAction(true);
        enderecoConsultaAction = new EnderecoAction(true);
        oficinaConsultaAction = new OficinaAction(true);
        veiculoConsultaAction = new VeiculoAction(true);
        vistoriaConsultaAction = new VistoriaAction(true);
        planoConsultaAction = new PlanoAction(true);
        sinistroConsultaAction = new SinistroAction(true);
        rateioConsultaAction = new RateioAction();
        usuarioConsultaAction = new UsuarioAction(true);
    }

    class FinallyApplicationAction extends AbstractAction {

        public FinallyApplicationAction() {
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            System.exit(0);
        }
    }

    class AssociadoAction extends AbstractAction {

        private boolean isConsult;

        public AssociadoAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            AssociadoDialog dialog = new AssociadoDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaAssociadoDialog dialog = new ConsultaAssociadoDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class ModeloAction extends AbstractAction {

        private boolean isConsult;

        public ModeloAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            ModeloDialog dialog = new ModeloDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaModeloDialog dialog = new ConsultaModeloDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class MarcaAction extends AbstractAction {

        private boolean isConsult;

        public MarcaAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            MarcaDialog dialog = new MarcaDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaMarcaDialog dialog = new ConsultaMarcaDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class GrupoAction extends AbstractAction {

        private boolean isConsult;

        public GrupoAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            GrupoDialog dialog = new GrupoDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaGrupoDialog dialog = new ConsultaGrupoDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class EnderecoAction extends AbstractAction {

        private boolean isConsult;

        public EnderecoAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            EnderecoDialog dialog = new EnderecoDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaEnderecoDialog dialog = new ConsultaEnderecoDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class OficinaAction extends AbstractAction {

        private boolean isConsult;

        public OficinaAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            OficinaDialog dialog = new OficinaDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaOficinaDialog dialog = new ConsultaOficinaDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class VeiculoAction extends AbstractAction {

        private boolean isConsult;

        public VeiculoAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            VeiculoDialog dialog = new VeiculoDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaVeiculoDialog dialog = new ConsultaVeiculoDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class VistoriaAction extends AbstractAction {

        private boolean isConsult;

        public VistoriaAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            CreateVistoriaDialog dialog = new CreateVistoriaDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaVistoriaDialog dialog = new ConsultaVistoriaDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class PlanoAction extends AbstractAction {

        private boolean isConsult;

        public PlanoAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            PlanoDialog dialog = new PlanoDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaPlanoDialog dialog = new ConsultaPlanoDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class SinistroAction extends AbstractAction {

        private boolean isConsult;

        public SinistroAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
            CreateSinistroDialog dialog = new CreateSinistroDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaSinistroDialog dialog = new ConsultaSinistroDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class RateioAction extends AbstractAction {

        @Override
        public void actionPerformed(ActionEvent e) {
            ConsultaRateioDialog dialog = new ConsultaRateioDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }

    class UsuarioAction extends AbstractAction {

        private boolean isConsult;

        public UsuarioAction(boolean isConsult) {
            this.isConsult = isConsult;
        }

        @Override
        public void actionPerformed(ActionEvent e) {
            if (isConsult) {
                runConsulta();
            } else {
                runCadastro();
            }
        }

        private void runCadastro() {
//            UsuarioDialog dialog = new UsuarioDialog(new javax.swing.JFrame(), true, StateEntityWindow.NEW, null);
//            dialog.setVisible(true);
        }

        private void runConsulta() {
            ConsultaUsuarioDialog dialog = new ConsultaUsuarioDialog(new javax.swing.JFrame(), true, StateEntityWindow.SEARCH);
            dialog.setVisible(true);
        }
    }
}
